package com.eshop.enums;

import java.util.stream.Stream;

public enum CouponEnum
{
    FALI_0(Integer.valueOf(0), "有效"), 
    FALI_1(Integer.valueOf(1), "无效"), 
    USE_0(Integer.valueOf(0), "不可用"), 
    USE_1(Integer.valueOf(1), "可用"), 
    STATUS_0(Integer.valueOf(0), "未使用"), 
    STATUS_1(Integer.valueOf(1), "已使用"), 
    STATUS_2(Integer.valueOf(2), "已过期"), 
    TYPE_0(Integer.valueOf(0), "通用券"), 
    TYPE_1(Integer.valueOf(1), "商品券"), 
    TYPE_2(Integer.valueOf(2), "内部券"), 
    PERMANENT_0(Integer.valueOf(0), "限量"), 
    PERMANENT_1(Integer.valueOf(1), "不限量");
    
    private Integer value;
    private String desc;
    
    public static CouponEnum toType(final int value) {
        return Stream.of(values()).filter(p -> p.value == value).findAny().orElse(null);
    }
    
    public Integer getValue() {
        return this.value;
    }
    
    public String getDesc() {
        return this.desc;
    }
    
    private CouponEnum(final Integer value, final String desc) {
        this.value = value;
        this.desc = desc;
    }
}
